; 实验七 寻址方式在结构化数据访问中的应用
assume cs:codesg,ds:datasg,ss:stacksg
datasg segment
        ; 21个数据 年份 0+[4]
        db '1975','1976','1977','1978','1979','1980','1981','1982','1983'
        db '1984','1985','1986','1987','1988','1989','1990','1991','1992'
        db '1993','1994','1995'
        ; 21个dword数据 收入 84+[4]
        dd 16,22,382,1356,2390,8000,16000,24486,50065,97479,140417,197514
        dd 345980,590827,803530,1183000,1843000,2789000,3753000,4649000,5937000
        ; 21个word数据 雇员 168+[2]
        dw 3,7,9,13,28,38,130,220,476,778,1001,1442,2258,2793,4037,5635,8226
        dw 11542,14430,15257,17800
datasg ends
table segment
        db 21 dup('year summ ne ?? ')
table ends
stacksg segment
        dw 0,0,0,0,0,0,0,0
stacksg ends
codesg segment
start:  
        mov ax,table
        mov ds,ax
        mov ax,datasg
        mov es,ax
        mov ax,stacksg
        mov ss,ax
        mov sp,10h
        ; 
        mov bx,0 ; ptr table
        mov bp,0 ; ptr data
        mov di,0 ; loop count
        mov cx,21 ;
s:      
        push cx
        ; year
        mov cx,4
        mov si,0
s1:     
        mov al,es:[bp+si]
        mov byte ptr ds:[bx+si],al
        inc si
        loop s1
        ; summery
        mov ax,es:[bp+84]
        mov ds:[bx+5],ax
        mov ax,es:[bp+86]
        mov ds:[bx+7],ax
        ; people
        mov ax,es:168[di]
        mov word ptr ds:[bx+0ah],ax
        ; div
        mov ax,[bx+5]
        mov dx,[bx+7]
        div word ptr [bx+0ah]
        mov [bx+0dh],ax
        add di,02h
        add bp,04h
        add bx,10h
        pop cx
        loop s

        mov ax,4c00h
        int 21h
codesg ends
end start